<?php

/**
 * Template for generating view
 * of one app in the Viewapps page
 * This block will include icon,
 * name of app linked to viewapp page
 * and "Edit app" link linked to 
 * /index.php?a=editapp&app_id=%d
 * 
 */
class tplApps extends StudyBuddy\Template\Template
{
	/**
	 * If App does not have 'icon' 
	 * then fall back to default generic
	 * app icon image
	 * 
	 * @param array $a
	 */
	protected static function func(&$a){
		if(empty($a['icon'])){
			$a['icon'] = '/images/app2.png';
		} else {
			$a['icon'] = STUDYBUDDY_AVATAR_IMG_SITE.\StudyBuddy\PATH_WWW_IMG_AVATAR_SQUARE.$a['icon'];
		}

		if(array_key_exists("app_name", $a)){
			$a['app_name'] = \trim($a['app_name']);
		}
	}


	protected static $vars = array(
	'_id' => '0', //1
	'app_name' => '', //2
	'about' => '', //3
	'icon' => '' //4
	);

	
	protected static $tpl = '
	<div class="cb fl mb10 mt10">
		<div class="fl">
			<a href="/index.php?a=viewapp&app_id=%1$s">
				<img src="%4$s" width="72px" height="72px" class="appicon"></img>
			</a>
		</div>
		<div class="fl ml10">
			<a href="/index.php?a=viewapp&app_id=%1$s" class="bold">%2$s</a>
			<br>
			<span class="fl mb5 pre">%3$s</span><br>
			<a href="/index.php?a=editapp&app_id=%1$s">Edit Details &gt;&gt;</a>
		</div>
	</div>
	';
}
